<?php
namespace Devcopilot\Controllers;

use Devcopilot\Controllers\Front;
use Devcopilot\Models\Requirement AS RequirementModel;
use Devcopilot\Models\Application AS ApplicationModel;
use Devcopilot\Models\Version AS VersionModel;
use Devcopilot\Models\Task AS TaskModel;

class Dashboard extends Front
{
    // 获取仪表盘统计数据
    public function getStats()
    {
        // 实际开发中会从数据库获取统计数据
        $req_model = new RequirementModel();
        // $app_model = new ApplicationModel();
        $ver_model = new VersionModel();
        $task_model = new TaskModel();
        $stats = [
            'pendingRequirements' => $req_model->getCount('wait'),
            'inProgressApplications' => 0,
            'developingVersions' => $ver_model->getCount('dev'),
            'pendingTasks' => $task_model->getCount('pending'),
        ];
        
        $this->ok($stats);
    }

    // 获取待处理任务列表
    public function queryPendingTasks()
    {
        // 实际开发中会从数据库获取待处理任务列表
        $task_model = new TaskModel();
        $pendingTasks = $task_model->queryPending();
        $this->ok($pendingTasks);
    }

    // 获取近期截止任务提醒
    public function getUpcomingDeadlines()
    {
        // 实际开发中会从数据库获取近期截止任务
        $upcomingDeadlines = [];
        
        $this->ok($upcomingDeadlines);
    }

     // 获取需求列表（用于关联需求下拉框）
    public function index()
    {
        $this->display('dashboard');
    }
}